package hcn.protocol.brandnew.feiyong.shoufei;

import com.fasterxml.jackson.annotation.JsonFormat;
import ctd.util.xml.jaxb.DateTimeAdapter;
import hcn.protocol.brandnew.BaseRequest;
import lombok.Data;
import org.atag.sysrouter.annotation.DictionaryMapping;

import javax.xml.bind.annotation.*;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import java.util.Date;
import java.util.List;


/**
 * 门诊结算信息新增-请求信息 - ODS_04010002
 *
 * @author enjoyLife
 */
@Data
@XmlRootElement(name = "MsgBody")
@XmlAccessorType(XmlAccessType.FIELD)
public class NotifyPayedRequest extends BaseRequest {

    /**
     * 就诊医疗机构组织机构代码
     */
    @XmlElement(name = "VisitOrganization")
    private String visitOrganization;
    /**
     * 医院内患者唯一标识
     */
    @XmlElement(name = "SourcePatientId")
    private String sourcePatientId;
    /**
     * 就诊序号
     */
    @XmlElement(name = "VisitId")
    private String visitId;;
    /**
     * 发票号码
     */
    @XmlElement(name = "InvoiceCode")
    private String invoiceCode;
    /**
     * 医疗付费方式代码
     */
    @XmlElement(name = "MedicalCostPayTypeCode")
    private String medicalCostPayTypeCode;
    /**
     * 支付标志
     */
    @XmlElement(name = "PayState")
    private String payState;
    /**
     * 第三方交易流水号
     */
    @XmlElement(name = "AgtOrderNumber")
    private String agtOrderNumber;
    /**
     * 商户订单号
     */
    @XmlElement(name = "OutOrderNumber")
    private String outOrderNumber;
    /**
     * 聚合支付交易流水号
     */
    @XmlElement(name = "ChannelOrderNumber")
    private String channelOrderNumber;
    /**
     * 支付成功时的通知信息
     */
    @XmlElement(name = "SettleNotify")
    private String settleNotify;
    /**
     * 预结算标识
     */
    @XmlElement(name = "PaymentBudgetNumber")
    private String paymentBudgetNumber;
    /**
     * 付款人
     */
    @XmlElement(name = "Payer")
    private String payer;
    /**
     * 结算日期时间
     */
    @XmlElement(name = "SettleDateTime")
    @XmlJavaTypeAdapter(DateTimeAdapter.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date settleDateTime;
    /**
     * 总计金额
     */
    @XmlElement(name = "TotalCost")
    private String totalCost;
    /**
     * 现金金额
     */
    @XmlElement(name = "PayAmount")
    private String payAmount;
    /**
     * 结算明细说明
     */
    @XmlElement(name = "ExtraFeeDesc")
    private String extraFeeDesc;
    /**
     * 医保报销总额
     */
    @XmlElement(name = "MedicalExpensesCost")
    private String medicalExpensesCost;
    /**
     * 医保支付集合
     */
    @XmlElementWrapper(name = "MedicalInsuranceCosts")
    @XmlElement(name = "MedicalInsuranceCost")
    private List<MedicalInsuranceCost> medicalInsuranceCosts;
    /**
     * 收费单据集合
     */
    @XmlElementWrapper(name = "FeeRecordLists")
    @XmlElement(name = "FeeRecordList")
    private List<FeeRecordList> feeRecordLists;

    //抵用券集合，2系Phis使用
    @XmlElementWrapper(name = "VoucherIdList")
    @XmlElement(name = "VoucherId")
    private List<String> voucherIdList;

    /**
     * 抵用券集合，4系Phis使用
     */
    @XmlElementWrapper(name = "VoucherIdList")
    @XmlElement(name = "VoucherId")
    private List<Voucher> voucherList;

    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class Voucher{
        /**
         * 抵用券对应的收费项目id
         */
        private String voucherItemId;
        /**
         * 抵用券id
         */
        private String voucherId;
    }

    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class MedicalInsuranceCost {

        /**
         * 医保支付方式
         */
        @XmlElement(name = "MedicalInsuranceCostTypeCode")
        private Byte medicalInsuranceCostTypeCode;
        /**
         * 医保支付金额
         */
        @XmlElement(name = "MedicalInsuranceCost")
        private String medicalInsuranceCost;
    }

    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class FeeRecordList {

        /**
         * 收费单据标识
         */
        @XmlElement(name = "FeeNo")
        private String feeNo;
        /**
         * 类型代码
         */
        @XmlElement(name = "FeeTypeCode")
        @DictionaryMapping(id = "hcn.base.dictionary.HCN_feeType")
        private String feeTypeCode;
        /**
         * 类型名称
         */
        @XmlElement(name = "FeeTypeName")
        private String feeTypeName;
    }

}
